<?php

namespace app\Common\listener;

class AppInit
{
    public $method = "DES-ECB";
    public function handle()
    {
        $this->initConst();
    }
    private function initConst()
    {
        $appDebug = \think\facade\Env::get("APP_DEBUG", false);
        defined("APP_DEBUG") || define("APP_DEBUG", $appDebug);
        defined("DS") || define("DS", '/');
        defined("APP_PATH") || define("APP_PATH", app_path());
        defined("LONGBING_ROOT_PATH") || define("LONGBING_ROOT_PATH", APP_PATH . ".." . DS);
        defined("ROOT_PATH") || define("ROOT_PATH", LONGBING_ROOT_PATH);
        defined("EXTEND_PATH") || define("EXTEND_PATH", LONGBING_ROOT_PATH . "extend/");
        defined("LONGBING_EXTEND_PATH") || define("LONGBING_EXTEND_PATH", APP_PATH . "Common/extend" . DS);
        defined("PAY_PATH") || define("PAY_PATH", LONGBING_ROOT_PATH);
        if(longbingIsWeiqin()) {
            global $_W;
            defined("APP_MODEL_NAME") || define("APP_MODEL_NAME", $_W["current_module"]["name"]);
            defined("UPLOAD_PATH") || define("UPLOAD_PATH", $_SERVER["DOCUMENT_ROOT"] . "/attachment/upload/" . DS);
            defined("PUBLIC_PATH") || define("PUBLIC_PATH", ADDON_PATH . "/core/public" . DS);
            defined("FILE_UPLOAD_PATH") || define("FILE_UPLOAD_PATH", LONGBING_ROOT_PATH . "../../../attachment" . DS);
            defined("MATER_UPLOAD_PATH") || define("MATER_UPLOAD_PATH", LONGBING_ROOT_PATH . "../../../attachment/file" . DS);
            defined("HTTPS_PATH") || define("HTTPS_PATH", "https://" . $_SERVER["HTTP_HOST"] . "/attachment" . DS);
            defined("H5_PATH") || define("H5_PATH", $_SERVER["DOCUMENT_ROOT"] . "/h5" . DS);
            defined("COACH_PATH") or defined("COACH_PATH") || define("COACH_PATH", $_SERVER["DOCUMENT_ROOT"] . "/coach/h5" . DS);
        } else {
            defined("H5_PATH") || define("H5_PATH", $_SERVER["DOCUMENT_ROOT"] . "/h5" . DS);
            defined("HTTPS_PATH") || define("HTTPS_PATH", "https://" . $_SERVER["HTTP_HOST"] . "/attachment" . DS);
            defined("MATER_UPLOAD_PATH") || define("MATER_UPLOAD_PATH", ROOT_PATH . "public/attachment/file" . DS);
            defined("HTTP_HOST") || define("HTTP_HOST", $_SERVER["HTTP_HOST"]);
            defined("APP_MODEL_NAME") || define("APP_MODEL_NAME", \think\facade\Config::get("app.AdminModelList.app_model_name", "longbing_card"));
            defined("UPLOAD_PATH") || define("UPLOAD_PATH", $_SERVER["DOCUMENT_ROOT"] . "/uploads" . DS);
            defined("PUBLIC_PATH") || define("PUBLIC_PATH", ROOT_PATH . "public" . DS);
            defined("FILE_UPLOAD_PATH") || define("FILE_UPLOAD_PATH", ROOT_PATH . "public/attachment" . DS);
            defined("COACH_PATH") || define("COACH_PATH", $_SERVER["DOCUMENT_ROOT"] . "/coach/h5" . DS);
        }
        $filesystemConfig = \think\facade\Config::get("filesystem");
        $filesystemConfig["disks"]["longbing"]["root"] = FILE_UPLOAD_PATH;
        \think\facade\Config::set($filesystemConfig, "filesystem");
    }
}

?>